#include <asm.h>
#include <regdef.h>
#include <inst_test.h>

LEAF(n41_mthi_test)
    .set noreorder
    addiu s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_MTHI(0xa0fd56b0, 0xa0fd56b0)
    TEST_MTHI(0x34036328, 0x34036328)
    TEST_MTHI(0x7dcad506, 0x7dcad506)
    TEST_MTHI(0x62caefdc, 0x62caefdc)
    TEST_MTHI(0x4ec1d4e2, 0x4ec1d4e2)
    TEST_MTHI(0xbb3dd000, 0xbb3dd000)
    TEST_MTHI(0xdac42a1c, 0xdac42a1c)
    TEST_MTHI(0x966e84ac, 0x966e84ac)
    TEST_MTHI(0x3bcd7b10, 0x3bcd7b10)
    TEST_MTHI(0xddc25525, 0xddc25525)
    TEST_MTHI(0x8bebf210, 0x8bebf210)
    TEST_MTHI(0xf964e610, 0xf964e610)
    TEST_MTHI(0x46e44b12, 0x46e44b12)
    TEST_MTHI(0xe2e6f846, 0xe2e6f846)
    TEST_MTHI(0x46ae8aa8, 0x46ae8aa8)
    TEST_MTHI(0x1191cd7f, 0x1191cd7f)
    TEST_MTHI(0xbd803578, 0xbd803578)
    TEST_MTHI(0x1302389a, 0x1302389a)
    TEST_MTHI(0x382371da, 0x382371da)
    TEST_MTHI(0x454f9e29, 0x454f9e29)
    TEST_MTHI(0x3832df89, 0x3832df89)
    TEST_MTHI(0x6f546cea, 0x6f546cea)
    TEST_MTHI(0xbf33bbb0, 0xbf33bbb0)
    TEST_MTHI(0x96402740, 0x96402740)
    TEST_MTHI(0xf8821e10, 0xf8821e10)
    TEST_MTHI(0x6db7e680, 0x6db7e680)
    TEST_MTHI(0x88a8dd60, 0x88a8dd60)
    TEST_MTHI(0x2c030dc6, 0x2c030dc6)
    TEST_MTHI(0xa2de3f98, 0xa2de3f98)
    TEST_MTHI(0x645215a3, 0x645215a3)
    TEST_MTHI(0xb7bd08c0, 0xb7bd08c0)
    TEST_MTHI(0x7003883c, 0x7003883c)
    TEST_MTHI(0xb4e0116c, 0xb4e0116c)
    TEST_MTHI(0x22bdca2a, 0x22bdca2a)
    TEST_MTHI(0x4567e2b5, 0x4567e2b5)
    TEST_MTHI(0x01f8285f, 0x01f8285f)
    TEST_MTHI(0x2033f310, 0x2033f310)
    TEST_MTHI(0x3c3e8e57, 0x3c3e8e57)
    TEST_MTHI(0x5792c206, 0x5792c206)
    TEST_MTHI(0x37037ada, 0x37037ada)
    TEST_MTHI(0x602ce460, 0x602ce460)
    TEST_MTHI(0x7e218364, 0x7e218364)
    TEST_MTHI(0x465ff380, 0x465ff380)
    TEST_MTHI(0x1faba8dd, 0x1faba8dd)
    TEST_MTHI(0xab455c80, 0xab455c80)
    TEST_MTHI(0x4460c128, 0x4460c128)
    TEST_MTHI(0xc7cad944, 0xc7cad944)
    TEST_MTHI(0xdec38e8e, 0xdec38e8e)
    TEST_MTHI(0x503a32a2, 0x503a32a2)
    TEST_MTHI(0x53001f30, 0x53001f30)
    TEST_MTHI(0x1d51e498, 0x1d51e498)
    TEST_MTHI(0xf80f1780, 0xf80f1780)
    TEST_MTHI(0x4add5ee1, 0x4add5ee1)
    TEST_MTHI(0x361ed76a, 0x361ed76a)
    TEST_MTHI(0xe5d71450, 0xe5d71450)
    TEST_MTHI(0x1cad6a18, 0x1cad6a18)
    TEST_MTHI(0xa3ce5b80, 0xa3ce5b80)
    TEST_MTHI(0x32919320, 0x32919320)
    TEST_MTHI(0xc4a4e200, 0xc4a4e200)
    TEST_MTHI(0xb4d611b0, 0xb4d611b0)
    TEST_MTHI(0x2f7f4c0c, 0x2f7f4c0c)
    TEST_MTHI(0xf1de70c4, 0xf1de70c4)
    TEST_MTHI(0xc4198cf8, 0xc4198cf8)
    TEST_MTHI(0x401a6554, 0x401a6554)
    TEST_MTHI(0xd67433e0, 0xd67433e0)
    TEST_MTHI(0x39b088da, 0x39b088da)
    TEST_MTHI(0x37410b1a, 0x37410b1a)
    TEST_MTHI(0x9a4afe50, 0x9a4afe50)
    TEST_MTHI(0x12b5de60, 0x12b5de60)
    TEST_MTHI(0xbd1c510c, 0xbd1c510c)
    TEST_MTHI(0x4f0bc620, 0x4f0bc620)
    TEST_MTHI(0x398fb9a8, 0x398fb9a8)
    TEST_MTHI(0x5092936d, 0x5092936d)
    TEST_MTHI(0x6251c1a0, 0x6251c1a0)
    TEST_MTHI(0x8daea63b, 0x8daea63b)
    TEST_MTHI(0x79cbb088, 0x79cbb088)
    TEST_MTHI(0x33130bb6, 0x33130bb6)
    TEST_MTHI(0x930a196a, 0x930a196a)
    TEST_MTHI(0x9e388580, 0x9e388580)
    TEST_MTHI(0x30ef0e30, 0x30ef0e30)
    TEST_MTHI(0xf8529c83, 0xf8529c83)
    TEST_MTHI(0xa322cf9f, 0xa322cf9f)
    TEST_MTHI(0x178baea0, 0x178baea0)
    TEST_MTHI(0xacdf244e, 0xacdf244e)
    TEST_MTHI(0x72c87f74, 0x72c87f74)
    TEST_MTHI(0xe2990f70, 0xe2990f70)
    TEST_MTHI(0x2ebdf808, 0x2ebdf808)
    TEST_MTHI(0x5b150768, 0x5b150768)
    TEST_MTHI(0x4d858c86, 0x4d858c86)
    TEST_MTHI(0x1680a180, 0x1680a180)
    TEST_MTHI(0xb53c7514, 0xb53c7514)
    TEST_MTHI(0x326af520, 0x326af520)
    TEST_MTHI(0xd05d2da8, 0xd05d2da8)
    TEST_MTHI(0x244b3ae0, 0x244b3ae0)
    TEST_MTHI(0xa2d7b966, 0xa2d7b966)
    TEST_MTHI(0xa9c67ce0, 0xa9c67ce0)
    TEST_MTHI(0x94b5f36c, 0x94b5f36c)
    TEST_MTHI(0x3e8297ea, 0x3e8297ea)
    TEST_MTHI(0x8d28d45c, 0x8d28d45c)
    TEST_MTHI(0xb9f6303c, 0xb9f6303c)
    TEST_MTHI(0x3324f55f, 0x3324f55f)
    TEST_MTHI(0xda57c2f0, 0xda57c2f0)
    TEST_MTHI(0x8a106518, 0x8a106518)
    TEST_MTHI(0xc6b2ae32, 0xc6b2ae32)
    TEST_MTHI(0x625d7728, 0x625d7728)
    TEST_MTHI(0x062991d6, 0x062991d6)
    TEST_MTHI(0x00000000, 0x00000000)
###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    sll t1, s0, 24
    or t0, t1, s3 
    sw t0, 0(s1)
    jr ra
    nop
END(n41_mthi_test)
